/**
 * @file html.h
 * @brief 数据的html描述文件的解析
 * @author nonono0ne
 * @version 1.0d
 * @date 2016-01-07
 * html描述文件主要使用html的table标签,暂时也只支持table的相关操作.
 *
 */

#ifndef _HAVE_TABLE_H
#define _HAVE_TABLE_H

/** td标签描述 */
typedef struct td {
    char *text;
    struct td *prev;
    struct td *next;
    struct table *table;    /**< 嵌套table */
}td_t;

typedef struct tr {
    struct td *tds;
    struct td *tail;
    struct tr *prev;
    struct tr *next;
}tr_t;

typedef struct table {
    char *caption;
    struct tr *trs;
    struct tr *tail;
    struct table *prev;
    struct table *next;
}table_t;

typedef struct tablelist {
    struct table *tables;
    struct table *tail;
    struct tablelist *prev;
    struct tablelist *next;
}table_list_t;

struct table *table_new();
void   table_free(struct table *t);
void   table_show(struct table *t);
char   *table_create_caption(struct table *t);
void   *table_delete_caption(struct table *t);
struct tr *table_insert_tr(struct table *t, int index);
struct tr *table_delete_tr(struct table *t, int index);

struct table *table_get_from_html(char *html);
struct field *table_to_fields(struct table *t);

#endif /* _HAVE_TABLE_H */
